package com.ctshk.sapp.finance.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.rpc.finance.dto.paidin.*;
import com.ctshk.rpc.finance.req.paidin.*;
import com.ctshk.rpc.finance.service.IFinancePaidInService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.ctshk.common.web.support.BaseController;

import javax.validation.Valid;

/**
 * <p>
 * 财务实付 前端控制器
 * </p>
 *
 * @author 叶冠峰
 * @since 2021-04-12
 */
@RestController
@Api(value = "财务实付", tags = "财务实付")
@RequestMapping("/finance-paid-in")
public class FinancePaidInController extends BaseController {

    @DubboReference
    private IFinancePaidInService paidInService;



    @ApiOperation(value = "列表", notes = "列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "财务实付-列表", operDesc = "财务实付-列表")
    @PostMapping("/list")
    public Result<PageResponse<PaidInListDTO>> list(@RequestBody PaidInListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.list(req);
    }

    @ApiOperation(value = "详情", notes = "详情（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "财务实付-详情", operDesc = "财务实付-详情")
    @PostMapping("/detail")
    public Result<PaidInDTO> detail(@RequestBody @Valid PaidInIdReq req) {
        return paidInService.detail(req);
    }

    @ApiOperation(value = "申请付款/编辑", notes = "申请付款/编辑（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.ADD, operTitle = "财务实付-申请付款/编辑", operDesc = "财务实付-申请付款/编辑")
    @PostMapping("/add")
    public Result add(@RequestBody @Valid PaidInAddReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.add(req);
    }

    @ApiOperation(value = "删除", notes = "删除（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.DELETE, operTitle = "财务实付-删除", operDesc = "财务实付-删除")
    @PostMapping("/del")
    public Result del(@RequestBody @Valid PaidInIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.del(req);
    }

    @ApiOperation(value = "提交审批", notes = "提交审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "财务实付-提交审批", operDesc = "财务实付-提交审批")
    @PostMapping("/commit")
    public Result commit(@RequestBody @Valid PaidInIdReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.commit(req);
    }

    @ApiOperation(value = "审批", notes = "审批（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.UPDATE, operTitle = "财务实付-审批", operDesc = "财务实付-审批")
    @PostMapping("/approval")
    public Result approval(@RequestBody @Valid PaidInApprovalReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.approval(req);
    }

    @ApiOperation(value = "供应商往来预订单列表", notes = "供应商往来预订单列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "财务实付-供应商往来预订单列表", operDesc = "财务实付-供应商往来预订单列表供应商往来预订单列表")
    @PostMapping("/supplier-order-list")
    public Result<PageResponse<PaidInsupplierOrderListDTO>> supplierOrderList(@RequestBody PaidInsupplierOrderListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.supplierOrderList(req);
    }


    @ApiOperation(value = "申请付款-付款预订单列表", notes = "申请付款-付款预订单列表（叶冠峰）")
    @OperationLogAnnotation(operModul = OperationLogModel.FINANCE, operType = OperationLogType.QUERY, operTitle = "财务实付-申请付款-付款预订单列表", operDesc = "财务实付-申请付款-付款预订单列表")
    @PostMapping("/pre-order-list")
    public Result<PaidInPreOrderDTO> preOrderList(@RequestBody @Valid PaidInPreOrderListReq req) {
        req.setUserId(getCurrentUser(getRequest()).getId());
        return paidInService.preOrderList(req);
    }


}
